package com.osmino.contacts.view.base;

import android.graphics.Color;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.osmino.contacts.LaunchActivity;
import com.osmino.contacts.R;
import com.osmino.contacts.model.contacts.ContactProviderAndroid;
import com.osmino.contacts.model.contacts.IContactProvider;
import com.osmino.contacts.view.IStyleableView;
import com.osmino.contacts.view.dialer.Dialer;
import com.osmino.contacts.view.list.ContactListView;
import com.osmino.contacts.view.style.Style;

public class BaseView extends RelativeLayout implements IStyleableView{
	
	Dialer d;
	ContactListView clv;
	
	public BaseView(LaunchActivity activity) {
		super(activity);
		setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
		
		setBackgroundColor(Color.WHITE);
		
		LinearLayout ll = new LinearLayout(activity);
		RelativeLayout.LayoutParams lp =  new RelativeLayout.LayoutParams(-1, 40);
		lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
		
		ll.setOrientation(LinearLayout.HORIZONTAL);
		
		RelativeLayout.LayoutParams taplp = new RelativeLayout.LayoutParams(60, 40);
		Tab tab1 = new Tab(activity, activity);
		tab1.setId(1);
		tab1.setPic(R.drawable.base_tab_keypad_ic);
		tab1.setText("keypad");
		tab1.setLayoutParams(taplp);
		
		Tab tab2 = new Tab(activity, activity);
		tab2.setId(2);
		tab2.setPic(R.drawable.base_tab_contacts_ic);
		tab2.setText("contact");
		tab2.setLayoutParams(taplp);
		
		ll.addView(tab1);
		ll.addView(tab2);
		
		
		
		ll.setLayoutParams(lp);
		
		d = new Dialer(activity, activity, null);
		RelativeLayout.LayoutParams dlp = new RelativeLayout.LayoutParams(-1, -1);
		dlp.setMargins(0, 0, 0, 40);
		d.setLayoutParams(dlp);
		
		
		
		clv = new ContactListView(activity, activity);
		ContactProviderAndroid provider = new ContactProviderAndroid(activity);
		clv.fill(provider.select());
		
		
		addView(clv);
		addView(d);
		addView(ll);
	}

	@Override
	public void setStyle(Style style) {
	}
	
	public void bringToFrontById(int id){
		if(id == 1)
			d.setVisibility(VISIBLE);
		if(id == 2)
			d.setVisibility(GONE);
	}
}